//此模块作用：把api进行统一管理
import requests from './ajax'
import mockRequests from './mockAjax'

//三级联动接口
//发请求：axios发送请求，结果返回Promise对象
export const reqCategoryList = () => {
    return requests({
        url: "/product/getBaseCategoryList",
        method: "GET"
    })
}
// 向mock发送请求,获取banner数据
export const reqBannerList = () => mockRequests.get("/banner");
// 获取floor数据
export const reqFloorList = () => mockRequests.get("/floor");
//获取search数据
export const reqSearchInfo = (params) => {
    return requests({
        url: "/list",
        method: "POST",
        data: params
    })
}
//获取产品详细信息的数据
export const reqGoodsInfo = (skuId) => {
    return requests({
        url: `/item/${skuId}`,
        method: "GET"
    })
}
//将产品加入购物车中
export const reqAddOrUpdateShopCart = (skuId, skuSum) => {
    return requests({
        url: `/cart/addToCart/${skuId}/${skuSum}`,
        method: "POST"
    })
}
//获取购物车列表
export const reqCartList = () => {
    return requests({
        url: "/cart/cartList",
        method: "GET"
    })
}
//删除购物车数据
export const reqDeleteCartItem = (skuId) => {
    return requests({
        url: `/cart/deleteCart/${skuId}`,
        method: "DELETE"
    })
}
//修改产品状态
export const reqCheckCartItem = (skuID, isChecked) => {
    return requests({
        url: `/cart/checkCart/${skuID}/${isChecked}`,
        method: "GET"
    })
}
//获取验证码
export const reqGetCode = (phone) => {
    return requests({
        url: `/user/passport/sendCode/${phone}`,
        method: "GET"
    })
}
//注册用户 /user/passport/register  phone code password
export const reqUserRegister = (data) => {
    return requests({
        url: "/user/passport/register",
        data,
        method: "post"
    })
}
//用户登陆
export const reqUserLogin = (data) => {
    return requests({
        url: "/user/passport/login",
        data,
        method: "post"
    })
}
//用户登录携带token获取用户信息
export const reqUserInfo = () => {
    return requests({
        url: "/user/passport/auth/getUserInfo",
        method: "get"
    })
}
//退出登录
export const reqLogout = () => {
    return requests({
        url: "/user/passport/logout",
        method: "get"
    })
}
//获取用户地址信息
export const reqUserAddressList = () => {
    return requests({
        url: "/user/userAddress/auth/findUserAddressList",
        metthod: "get"
    })
}
//获取商品清单数据
export const reqOrderInfo = () => {
    return requests({
        url: "/order/auth/trade",
        method: "get"
    })
}
//提交订单，获取订单信息
export const reqSubmitOrder = (tradeNo, data) => {
    return requests({
        url: `/order/auth/submitOrder?tradeNo=${tradeNo}`,
        data,
        method: "post"
    })
}
//获取订单支付信息
export const reqPayInfo = (orderId) => {
    return requests({
        url: `/payment/weixin/createNative/${orderId}`,
        method: "get"
    })
}
//获取用户支付状态
export const reqPayStatus = (orderId) => {
    return requests({
        url: `/payment/weixin/queryPayStatus/${orderId}`,
        method: "get"
    })
}
//获取个人订单列表
export const reqMyOrderList = (page, limit) => {
    return requests({
        url: `/order/auth/${page}/${limit}`,
        method: "get",
    })
}